﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {
        public void UBTFQI03E()
        {
            try
            {
                DataTable dtrSoruce = dsSource.Tables["WBBST"];
                DataTable dtVAART = dsSource.Tables["VAART"];
                string WBBSTKNR = "", ORDERNO = "", ART = "",FARBE="", BARCODE = "",src="",SP="";
                if (dtVAART.Rows.Count > 0)
                {
                    DataRow dwVAART = dtVAART.Rows[0];
                    src = dwVAART["ARTNAME"].ToString().Trim(); 
                } 
            
                int x = dsSource.Tables["WBBST"].Rows.Count;
                int i = 0;
                int rows = 8;
                foreach (DataRow dw in dtrSoruce.Rows)
                {
                    ART = dw["WBBART"].ToString().Trim();
                    //ORDERNO = dw["ORDERNO"].ToString().Trim();
                    FARBE = dw["WBBFARBE"].ToString().Trim();
                    BARCODE = "*" + dw["WBBSTKNR"].ToString().Trim() + "*";
                    WBBSTKNR = dw["WBBSTKNR"].ToString().Trim();
                    SP = dw["REMARK"].ToString().Trim();
                    exAgent.SetCellValue(i * rows + 1, 1, "品号：");
                    exAgent.SetCellValue(i * rows + 1, 4, ART+"  -"+FARBE);
                    //exAgent.SetCellValue(i * rows + 1, 13, FARBE);
                    exAgent.SetCellValue(i * rows + 2, 1, "品名："); 
                    exAgent.SetCellValue(i * rows + 2, 4, Helpers.Helper.GetGB2312Value(src).Trim());
                    exAgent.SetCellValue(i * rows + 3, 1, "批号：");
                    exAgent.SetCellValue(i * rows + 5, 1, x+"-"+(i+1));
                    exAgent.SetCellValue(i * rows + 3, 4, Helpers.Helper.GetGB2312Value(SP).Trim());
                    exAgent.SetCellValue(i * rows + 6, 1, BARCODE);
                    exAgent.SetCellValue(i * rows + 8, 1, WBBSTKNR);
                    i = i + 1;
                    if (i < x)
                    {
                        exAgent.RangeCopy(1, 8, i * 8 + 1, i * 8 + 8);
                    }                  
                }
                exAgent.Save();
                exAgent.FileName = DestFile;
                DirectPrint(DestFile); 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        } 
    }
}